<?php
/**
 * 微信支付验证
 */
/**
 * 微信支付验证
 */
define('IN_IA',true);
include_once '../../data/config.php';
header('Content-type:text/html;charset=utf-8');
error_reporting(0);


function array2Xml($_data)
{
    $XmlWrite = new XMLWriter();
    $XmlWrite->openMemory();
    $XmlWrite->startDocument('1.0', 'UTF-8');
    $XmlWrite->startElement('xml');
    foreach ($_data as $_k=>$_v){
        $XmlWrite->startElement($_k);
        $XmlWrite->writeCdata($_v);
        $XmlWrite->endElement();
    }
    $XmlWrite->endElement();
    return $XmlWrite->outputMemory();
}

$_input = file_get_contents('php://input');

if(empty($_input)){
    $_result = array(
        "return_code"=>"FAIL",
        "return_msg" => "empty"
    );
    echo array2Xml($_result);
    exit;
}

$_data = simplexml_load_string($_input);

if ($_data->result_code != 'SUCCESS' || $_data->return_code != 'SUCCESS') {
    $result = array(
        'return_code' => 'FAIL',
        'return_msg' => empty($_data['return_msg']) ? $_data['err_code_des'] : $_data['return_msg']
    );
    echo array2xml($result);
    exit;
}


$_result = array(
    "return_code"=>"SUCCESS",
    "return_msg"=>"OK"
);
echo array2Xml($_result);
exit;
